#include "Particle.h"
#include "MyGL.h"
#include "Timer.h"
#include <cmath>
#include <iostream>
#include <assert.h>

namespace Engine
{
	void Particle::Update()
	{
		if(m_inverseMass == 0.0f)
		{
			m_force.x = m_force.y = m_force.z = 0.0f;
			return;
		}

		m_acc = m_force * m_inverseMass;

		Vec3 oldVel = m_vel;
		m_vel += m_acc * 0.9f;//dampening force

		m_pos += (((oldVel + m_vel) * .5f) * TheTimer::Instance() ->GetDT());

		m_force.x = m_force.y = m_force.z = 0.0f;
	}
	
	void Particle::Draw()
	{
		glBegin(GL_POINTS);
			glColor3f(1.0f, 1.0f, 1.0f);
			glVertex3fv(m_pos.ToArray());
		glEnd();
	}
}